package com.telsoft.hms.function;

import com.telsoft.hms.data.GetInfoRigsPatient_DATA;
import com.telsoft.hms.entity.ETT_InfoRegisPatient;
import com.telsoft.hms.lib.security.exception.SessionNotExistsException;
import com.telsoft.hms.lib.security.exception.UserNotExistsException;
import com.telsoft.hms.lib.security.server.WsRuntime;
import com.telsoft.hms.lib.security.session.Session;

public class HMS_GetInfoRigsPatient {
	public ETT_InfoRegisPatient getInfoRigsPatient(int patientID, int regisID,
			String securityKey, String username) throws Exception {
		String hospitalKey = null;
		if (patientID == 0) {
			throw new Exception("ERR-0012");
		} else if (regisID == 0) {
			throw new Exception("ERR-0011");
		} else if (securityKey.equals("")) {
			throw new Exception("ERR-0010");
		} else if (username.equals("")) {
			throw new Exception("ERR-0006");
		} else {
			// validate security key
			try {
				WsRuntime wsRunTime = new WsRuntime();
				Session session = wsRunTime.validateSecurity(securityKey);
				hospitalKey = session.getHospitalKey();
				if (!hospitalKey.equals("")) {
					GetInfoRigsPatient_DATA getInfo = new GetInfoRigsPatient_DATA();
					return getInfo.getInfoRigsPatient(patientID, regisID,
							hospitalKey);
				}
			} catch (UserNotExistsException e) {
				throw new Exception("SK-0002");
			} catch (SessionNotExistsException e1) {
				throw new Exception("SK-0001");
			}
		}
		return null;
	}
}
